<?php 
/*
 module:		Mbti订单表
 create_time:	2024-04-17 16:53:14
 author:		
 contact:		
*/

namespace app\api\service;
use app\api\model\Order;
use think\facade\Db;
use think\facade\Log;
use think\exception\ValidateException;
use xhadmin\CommonService;

class UrlballbackService extends CommonService {


	/*
 	* @Description  更新订单
 	*/
	public static function wxnotify($data){
		try{
//            $data['out_trade_no'],$data['openid'],$data['transaction_id']
            Db::name("order_record")
                ->where("sc_order",$data['out_trade_no'])
                ->update(["pay_order"=>$data['transaction_id'],"pay_time"=>time(),"state"=>1]);
            $parmen = [];
            $parmen["state"] = 1;
            $parmen["pay_time"] = time();
            $parmen["openid"] = $data['openid'];
            $parmen["type"] = 1;
            $where = [];
            $where["order_id"] =  Db::name("order_record")->where("sc_order",$data['out_trade_no'])->value("o_id");
			$res = Order::update($parmen,$where);

		}catch(ValidateException $e){
			throw new ValidateException ($e->getError());
		}catch(\Exception $e){
			abort(config('my.error_log_code'),$e->getMessage());
		}
	}




}

